<!DOCTYPE html>
<html lang='en'>

<head>
  <meta charset='UTF-8'>
  <meta http-equiv='X-UA-Compatible' content='IE=edge'>
  <meta name='viewport' content='width=device-width, initial-scale=1.0'>
  <title>Document</title>
  <script src='https://cdn.jsdelivr.net/npm/vue/dist/vue.js'></script>
</head>

<body>
  <div id='app'>
    <h2>{{message}}</h2>
    <fa-cpn></fa-cpn>
  </div>
  <script>
    // 创建子组件构造器
    const chComponent = Vue.extend({
        template: `<div>
        <h2>我是子组件</h2>
        <p>我是子组件的内容</p>
        </div>`
      })
      // 1.创建父组件构造器
    const faComponent = Vue.extend({
      template: `<div>
        <h2>我是父组件</h2>
        <p>我是父组件的内容</p>
        <ch-cpn />
        </div>`,
      // 注册组件为父组件局部组件
      components: {
        'ch-cpn': chComponent
      }
    })

    // 2.注册为全局父组件
    Vue.component('fa-cpn', faComponent)
    const app = new Vue({
      el: '#app',
      data: {
        message: 'hello world'
      }
    })
  </script>
</body>

</html>